          
          
         
          var originalWidth = consultWidth = window.innerWidth;
          //var linkJumpCount = 16;
          var linkHref;
          var beginningDelay = null;
          var animateDelayCount = 4000;
          var watchWindowWidth = null;
          var scrollOld,scrollNew,scrollNewHor,scrollOldHor;
          var horizontal = false;
          var scrollDown = '';
          var scrollStart = false;
          var scrollIntvl = null;
          var scrollStep = 20;
          var barOpacity = null;
          var watchScrollTop = null;
          var consultScroll;
          var mobileWatchingTop = null;
            function countDown(){
                linkJumpCount -= 1;
                //linkJumpCount=0时，跳转页面
                if(linkJumpCount <= 0){
                    location.href = linkHref;
                }

                //每秒执行一次,showTime()
                setTimeout("countDown()",100);
            }
            //内容高度是否小于屏幕高度
            function checkContnHeight(){
                if($('.container')[0].offsetHeight < window.innerHeight){
                    $('.container').addClass('fillAll');
                }
            }
            //判断是否为移动设备
            function browserRedirect(){
                var sUserAgent = navigator.userAgent.toLowerCase();
                var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
                var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
                var bIsMidp = sUserAgent.match(/midp/i) == "midp";
                var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
                var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
                var bIsAndroid = sUserAgent.match(/android/i) == "android";
                var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
                var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
                if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) {
                    $('body').addClass('mobileDevice');
                    return true;
                }else{
                    return false;
                }
            }
            //禁止滚动
            function onMouseScroll(e){
                e.preventDefault();
                var wheel = e.originalEvent.wheelDelta || -e.originalEvent.detail;
                var delta = Math.max(-1, Math.min(1, wheel) );
                if(delta < 0){//向下滚动
                    scrollDown = true;
                    //console.log('下');
                }else{//向上滚动
                    scrollDown = false;
                    //console.log('上');
                }
                custmzScroll();
            }

            function custmzScroll(){
                var bodyH = $('body')[0].offsetHeight;
                var canScroll = parseInt(bodyH - window.innerHeight);
                var bodyW = window.innerWidth * .4 - $('header .tpLft')[0].offsetWidth + $('header .menu .products .palace')[0].offsetWidth; 
                var canScrollHor = parseInt(bodyW - (window.innerWidth - $('header .tpLft')[0].offsetWidth));
                canScrollHor < 0 && (canScrollHor = 0);
                if(horizontal){
                    if(window.innerWidth <= 1024) return false;
                    if(scrollDown){
                        scrollNewHor += 100;
                        scrollNewHor > canScrollHor && (scrollNewHor = canScrollHor);
                    }else{
                        scrollNewHor -= 100;
                        scrollNewHor < 0 && (scrollNewHor = 0);
                    }
                    if(scrollNewHor == canScrollHor && canScrollHor != 0){
                        $('header .menu .products .btnBox .btn').addClass('rotate');
                    }else{
                        $('header .menu .products .btnBox .btn').removeClass('rotate');
                    }
                    $('header.flip .menu .products .classify').addClass('noDelay');
                }else{
                    if(scrollDown){
                        scrollNew += 100;
                        scrollNew > canScroll && (scrollNew = canScroll);
                    }else{
                        scrollNew -= 100;
                        scrollNew < 0 && (scrollNew = 0);
                    }
                }
                
                scrollStart = true;
            }
            function updateScroll(val){
                if(horizontal){
                    $('header.flip .menu')[0].style.transform = 'translateX(-' + val + 'px)';
                }else{
                    document.documentElement.scrollTop = document.body.scrollTop = val;
                    clearTimeout(barOpacity);
                    $('.scroll .bar').addClass('appear');
                    barOpacity = setTimeout(function(){
                        $('.scroll .bar').removeClass('appear');
                    },2000)
                }
                
            }
            watchScrollTop = setInterval(function(){
                var bodyH = $('body')[0].offsetHeight;
                var canScroll = parseInt(bodyH - window.innerHeight);
                var scrollTop = document.documentElement.scrollTop || document.body.scrollTop
                var percent = scrollTop / canScroll;
                var barCanRoll = window.innerHeight - $('.scroll .bar').height();
                var topVal = percent * barCanRoll;
                $('.scroll .bar')[0].topVal = topVal;
                $('.scroll .bar')[0].style.transform = 'translateY(' + topVal + 'px)';
            },10)
            scrollIntvl = setInterval(function(){
                if(!scrollStart) return false;
                if(horizontal){
                    if(scrollNewHor > scrollOldHor){
                        scrollOldHor += Math.ceil((scrollNewHor - scrollOldHor) / scrollStep);
                    }else{
                        scrollOldHor -= Math.ceil((scrollOldHor - scrollNewHor) / scrollStep);
                    }
                    $('header .menu .products .btnBox')[0].style.transform = 'translateX(' + scrollOldHor + 'px)';
                    var navCanScroll = parseInt(window.innerWidth * .4 - $('header .tpLft')[0].offsetWidth - 20);
                    if(scrollOldHor > navCanScroll){
                        $('header.flip .menu .products .classify')[0].style.transform = 'translateX(' + (scrollOldHor - navCanScroll) + 'px)';
                    }else{
                        $('header.flip .menu .products .classify').css('transform','translateX(0px)');
                    }
                    updateScroll(scrollOldHor);
                }else{
                    if(scrollNew > scrollOld){
                        scrollOld += Math.ceil((scrollNew - scrollOld) / scrollStep);
                    }else{
                        scrollOld -= Math.ceil((scrollOld - scrollNew) / scrollStep);
                    }
                    updateScroll(scrollOld);
                }
                
                if(scrollNew == scrollOld && scrollNewHor == scrollOldHor){
                    scrollStart = false;
                    $('header.flip .menu .products .classify').removeClass('noDelay');
                    scrollDown = '';
                }
            },10)

            $(document).ready(function(){
                    browserRedirect(); 
                    
                    setTimeout(checkContnHeight,10);
                    setTimeout(function(){
                        scrollOld = scrollNew = document.documentElement.scrollTop = document.body.scrollTop = scrollNewHor = scrollOldHor = 0;
                        consultScroll = document.documentElement.scrollTop || document.body.scrollTop;
                    },10)
                    /*mobileWatchingTop = setInterval(function(){
                        if(!$('.mobileDevice').length) return false;
                        var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
                        if(consultScroll != scrollTop){
                            if($('.scroll .bar')[0].className.indexOf('appear') < 0){
                                $('.scroll .bar').addClass('appear');
                                barOpacity = setTimeout(function(){
                                    $('.scroll .bar').removeClass('appear');
                                },2000)
                            }
                            consultScroll = scrollTop;
                            
                        }
                    })*/

                    $('header .tpLft .menuBtn').click(function(){
                        if($(this)[0].className.indexOf('clicked') >= 0){
                            $(this).removeClass('clicked');
                            $('header').removeClass('flip');
                            $('header.flip .menu .products .classify').removeClass('noDelay');
                            horizontal = false;
                        }else{
                            $(this).addClass('clicked');
                            $('header').addClass('flip');
                            horizontal = true;
                        }
                    })
                    $('header .menu .products .classify p:eq(0)').addClass('active');
                    $('header .menu .products .classify p').click(function(){
                        $('header .menu .products .classify p').removeClass('active');
                        $(this).addClass('active');
                    })
                    $('header .menu .products .btnBox .btn').click(function(){
                        var bodyW = window.innerWidth * .4 - $('header .tpLft')[0].offsetWidth + $('header .menu .products .palace')[0].offsetWidth + 50; 
                        var canScrollHor = parseInt(bodyW - (window.innerWidth - $('header .tpLft')[0].offsetWidth));
                        if($(this)[0].className.indexOf('rotate') >= 0){
                            $(this).removeClass('rotate');
                            scrollNewHor = 0;
                        }else{
                            scrollNewHor += parseInt(window.innerWidth / 2);
                            scrollNewHor > canScrollHor && (scrollNewHor = canScrollHor);
                        }
                        if(scrollNewHor == canScrollHor){
                            $('header .menu .products .btnBox .btn').addClass('rotate');
                        }else{
                            $('header .menu .products .btnBox .btn').removeClass('rotate');
                        }
                        scrollStart = true;
                        $('header.flip .menu .products .classify').addClass('noDelay');
                    })

                    $('header .menu .products .classify p').click(function(){
                        var cat = $(this).attr('data-categories');
                        $('header .menu .products .palace .item').addClass('disappear');
                        setTimeout(function(){
                            $('header .menu .products .palace .item').removeClass('hidden');
                            for(var i = 0;i < $('header .menu .products .palace .item').length;i++){
                                var thisCat = $('header .menu .products .palace .item')[i].getAttribute('data-categories');
                                if(thisCat != cat && cat != 'all'){
                                    $('header .menu .products .palace .item:eq(' + i + ')').addClass('hidden');
                                }else{
                                    $('header .menu .products .palace .item:eq(' + i + ')').removeClass('disappear');
                                }
                            }
                        },610)
                        scrollNewHor = 0;
                        scrollStart = true;
                        $('header.flip .menu .products .classify').addClass('noDelay');
                    })

                    $('.scroll .bar').mousedown(function(se){
                        $(this).attr('canmove','true');
                        var sEvnt = se.event || window.event;
                        var startY = sEvnt.clientY;
                        var This = $(this);
                        var eleY = This[0].topVal;
                        $(document).mousemove(function(eve){
                            if(This.attr('canmove') != 'true') return false;
                            var oe = eve.event || window.event;
                            var mouseY = oe.clientY;
                            var topVal = eleY + (mouseY - startY);
                            var eleH = This[0].offsetHeight;
                            var bodyH = $('body')[0].offsetHeight;
                            var canScroll = parseInt(bodyH - window.innerHeight);
                            var barCanRoll = window.innerHeight - eleH;
                            var percent = topVal / barCanRoll;
                            if(percent < 0){
                                percent = 0;
                            }else if(percent > 1){
                                percent = 1;
                            }
                            var val = parseInt(percent * canScroll);
                            updateScroll(val);
                            scrollNew = scrollOld = val;
                        })
                    })

                    $(document).mouseup(function(){
                        $('.scroll .bar').attr('canmove','false');
                    })

                    $('.scroll').mouseup(function(te){
                        var tEvnt = te.event || window.event;
                        var topVal = tEvnt.clientY - $(this).find('.bar').height() / 2;
                        var barCanRoll = window.innerHeight - $(this).find('.bar').height();
                        if(topVal < 0){
                            topVal = 0;
                        }else if(topVal > barCanRoll){
                            topVal = barCanRoll;
                        }
                        var percent = topVal / barCanRoll;
                        var bodyH = $('body')[0].offsetHeight;
                        var canScroll = parseInt(bodyH - window.innerHeight);
                        var val = parseInt(percent * canScroll);
                        scrollStart = true;
                        scrollNew = val;
                    })
                    function checkUrlNow(){
                        var linkNow = window.location.href;
                        for(var a = 0;a < $('header .menu .side nav a').length;a++){
                            var href = $('header .menu .side nav a')[a].getAttribute('href').split('.')[0];
                            href == 'itemInfo' && (href = 'item');
                            if(linkNow.indexOf(href) >= 0){
                                $('header .menu .side nav a:eq(' + a + ')').addClass('current');
                                $('footer nav a:eq(' + a + ')').addClass('current');
                            }
                        }
                        if(!$('header .menu .side nav a.current').length){
                            $('header .menu .side nav a:eq(0)').addClass('current');
                            $('footer nav a:eq(0)').addClass('current');
                        }
                    }
                    checkUrlNow();
                    
                    
                    /*$('a').click(function(e){
                        
                            linkHref = $(this).attr('href');
                            e = e || window.event;
                            e.cancelBubble = true;
                            e.stopPropagation();
                            if(e.preventDefault){ // w3c
                                e.preventDefault();
                            } else { // ie
                                e.returnValue = false;
                            }
                            countDown();
                            $('.leaving').addClass('jump');
                            $('.container').addClass('jump');
                    })*/
                    
            })

            $(document).on('mousewheel DOMMouseScroll', onMouseScroll);
            